package com.nadina.home.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.HeadElement;
import com.google.gwt.dom.client.LinkElement;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.nadina.shaerd.client.Banner;
import com.nadina.shaerd.client.Footor;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Home implements EntryPoint {

	public void onModuleLoad() {

		injectThemeStyleSheet();

		VerticalPanel mainpanel = new VerticalPanel();
		mainpanel.setWidth("100%");
		mainpanel.setHeight(Window.getClientHeight() + "px");

		Banner banner = new Banner();
		banner.setWidth("100%");
		mainpanel.add(banner);
		mainpanel.setCellHeight(banner, "81px");

		HomeContent homeContent = new HomeContent();
		mainpanel.add(homeContent);
		
		Footor footor=new Footor();
		footor.setWidth("100%");
		mainpanel.add(footor);
		mainpanel.setCellHeight(footor, "81px");
		mainpanel.setCellVerticalAlignment(footor, HasVerticalAlignment.ALIGN_BOTTOM);

		RootPanel.get().add(mainpanel);

	}

	private native HeadElement getHeadElement() /*-{
		return $doc.getElementsByTagName("head")[0];
	}-*/;

	/**
	 * Inject the GWT theme style sheet based on the RTL direction of the
	 * current locale.
	 */
	private void injectThemeStyleSheet() {
		// Choose the name style sheet based on the locale.
		String styleSheet;
		styleSheet = "gwt/standard/standard_rtl.css";

		// Load the GWT theme style sheet
		String modulePath = GWT.getModuleBaseURL();
		LinkElement linkElem = Document.get().createLinkElement();
		linkElem.setRel("stylesheet");
		linkElem.setType("text/css");
		linkElem.setHref(modulePath + styleSheet);
		getHeadElement().appendChild(linkElem);
	}
}
